﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//
using PerceptiveMCAPI;
using PerceptiveMCAPI.Types;
using System.Data;
//

namespace PerceptiveMCAPI_Test
{
   public partial class show_listInterestGroups : System.Web.UI.UserControl
   {
      public void Display( listInterestGroupsOutput output )
      {
         this.Visible = true;
         // ------------------------------------------------
         // manual format to get interest groups to display
         // ------------------------------------------------
         if ( output.api_ErrorMessages.Count == 0 && output.result.groups.Count > 0 )
         {
            DataTable tbl = new DataTable( "IntGroup" );
            tbl.Columns.Add( "Name" ); tbl.Columns.Add( "Form_Field" ); tbl.Columns.Add( "Groups" );

            DataRow row = tbl.NewRow();
            row["Name"] = output.result.name;
            row["Form_Field"] = output.result.form_field;
            output.result.groups.Sort();
            row["Groups"] = ApiHelper.MakeStringHtmlStackFromList( output.result.groups );
            tbl.Rows.Add( row );
            // ------------------------------------------------
            dvInterestGroups.DataSource = tbl;
            dvInterestGroups.HeaderText = string.Format( "List Interest Groups &mdash;&nbsp;{0}", output.inputParms.id );
            dvInterestGroups.DataBind();
         }
         else
         { dvInterestGroups.DataSource = ""; dvInterestGroups.DataBind(); }
      }
   }
}